package com.lg.erp.controller.zhangchaofu;

import com.lg.erp.entity.JsonResult;
import com.lg.erp.entity.zhangchaofu.TIomWarehouse;
import com.lg.erp.entity.zhangchaofu.ZCFTIoWarehouse;
import com.lg.erp.entity.zhangchaofu.ZCFTProductHandover;
import com.lg.erp.service.zhangchaofu.InAndOutWarehouseSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class InAndOutWarehouseController {

    @Autowired
    private InAndOutWarehouseSevice inAndOutWarehouseSevice;

    /**
     * 查询交接单的所有商品
     * @return
     */
    @GetMapping("inWarehouse-productHandover")
    public JsonResult findInWarehouseProductHandover(){
        List<ZCFTProductHandover> productHandover =inAndOutWarehouseSevice.findInWarehouseProductHandover();
        return new JsonResult(1,"ok",productHandover);
    }

    /**
     * 根据交接单类型查询相应的商品
     * @param type
     * @return
     */
    @GetMapping("/inWarehouse-productHandover-type/{type}")
    public JsonResult findInWarehouseProductHandoverType(@PathVariable("type") String type){
        List<ZCFTProductHandover> productHandover =inAndOutWarehouseSevice.findInWarehouseProductHandoverType(type);
        return new JsonResult(1,"ok",productHandover);
    }

    /**
     * 添加入库详情表信息
     * @param tIomWarehouse
     * @return
     */
    @PutMapping("/inWarehouse-iomWarehouse-inWare")
    public JsonResult addIomWarehouse(@RequestBody TIomWarehouse tIomWarehouse){
        inAndOutWarehouseSevice.addIomWarehouse(tIomWarehouse);
        return new JsonResult(1,"ok",null);
    }

    /**
     * 添加入库信息
     * @param ioWarehouse
     * @return
     */
    @PostMapping("/inWarehouse-inWare")
    public JsonResult addInWarehouse(@RequestBody ZCFTIoWarehouse ioWarehouse){
        inAndOutWarehouseSevice.addInWarehouse(ioWarehouse);
        return new JsonResult(1,"ok",null);
    }
}
